﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THenu.TinyHourseLib.DesignPattern.Behavioral_Patterns.Commond_Pattern
{
    /// <summary>
    /// Command
    /// </summary>
    abstract class Command
    {
        protected Receiver receiver;

        public Command(Receiver receiever)
        {
            this.receiver = receiever;
        }
        public abstract void Execute();
    }
    /// <summary>
    /// ConcreteCommand
    /// </summary>
    class ConcreteCommand : Command
    {
        public ConcreteCommand(Receiver receiever)
            :base(receiever)
        {
        }

        public override void Execute() { receiver.Action(); }
    }
    /// <summary>
    /// Receiver
    /// </summary>
    public class Receiver
    {
        public void Action()
        {
            Console.WriteLine("Called Receiver.Action()");
        }
    }
    class Invoker
    {
        private Command command;

        public void SetCommand(Command command)
        {
            this.command = command;
        }

        public void ExecuteCommand()
        {
            command.Execute();
        }
    }
}
